import QtQuick 2.0
import QtQuick.Window 2.12
import QtQuick.Controls 2.14
import Qt.labs.qmlmodels 1.0

Rectangle{
    id:listview
    anchors.top: file_connect.bottom
    anchors.bottom: file_connect.bottom
    anchors.left: file_connect.left
    anchors.right: file_connect.right
    anchors.topMargin: 2
    color: "black"
    Rectangle{
        id:header
        anchors.topMargin: 5
        anchors.left: listview.left
        anchors.leftMargin: 5
        anchors.right: listview.right
        anchors.rightMargin: 5
        width: listview.width-10
        height: 30
        Row {
            spacing: 0
            Repeater{
                model:["设备名(套接字名)","主机名","选择"]
                Rectangle{
                    width: header.width/3
                    height: header.height
                    color: "red"
                    border.width: 1
                    border.color: "black"
                    Text {
                        text: modelData
                        anchors.centerIn: parent
                        font.pointSize: 12
                        color: "white"
                    }
                }
            }
        }
    }
    ListView{
        id:listview2
        width: parent.width
        anchors.top: header.bottom
        anchors.topMargin: 10
        anchors.left: listview.left
        anchors.leftMargin: 5
        anchors.right: listview.right
        anchors.rightMargin: 5
        anchors.bottom: listview.bottom
        spacing: 4
        clip: true
        displaced: Transition {
            NumberAnimation { properties: "x,y"; easing.type: Easing.OutQuad }
        }
         model: ListModel { id: devicemanager }
         delegate: Component {

             Row {
                 Rectangle {
                     width: (listview2.width)/3
                     height: 32
                     radius: 2
                     border.color: "#777"
                     color: hovered ? "#559EF2FA" : "#55556677"
                     property bool hovered: false

                     MouseArea {
                         anchors.fill: parent
                         hoverEnabled: true
                         onEntered: parent.hovered = true;
                         onExited: parent.hovered = false;
                         onClicked: {
                            // scanner.stop();
                             //discoverCon.connectToName(name);
                             //fileTransfer.setAccessPoint(name);
                            // root.connected = true;
                            // root.connectName = name;
                             //devicemanager.clear();
                         }
                     }

                     Text {
                         anchors.centerIn: parent
                         text: qsTr(name)
                     }
                 }
                 Rectangle {
                     width: (listview2.width)/3
                     height: 32
                     radius: 2
                     border.color: "#777"
                     color: hovered ? "#559EF2FA" : "#55556677"
                     property bool hovered: false

                     MouseArea {
                         anchors.fill: parent
                         hoverEnabled: true
                         onEntered: parent.hovered = true;
                         onExited: parent.hovered = false;
                         onClicked: {
                             //devicemanager.clear();
                         }
                     }

                     Text {
                         anchors.centerIn: parent
                         text: qsTr(ipaddress)
                     }
                 }
                 Rectangle {
                     width: (listview.width)/3
                     height: 32
                     radius: 2
                     border.color: "#777"
                     color: hovered ? "#559EF2FA" : "#55556677"
                     property bool hovered: false

                     MouseArea {
                         anchors.fill: parent
                         hoverEnabled: true
                         onEntered: parent.hovered = true;
                         onExited: parent.hovered = false;
                         onClicked: {
                             //devicemanager.clear();
                         }
                     }

                     Text {
                         anchors.centerIn: parent
                         text: qsTr(thetime)
                     }
                 }
             }

          }
    }
}
